package me.zy.service;

import me.zy.entity.Product;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * Created by yuzhou on 2017/10/9.
 */
@Service("productService")
public class ProductService {

  private static final Logger _log = LoggerFactory.getLogger(ProductService.class);

  public List<Product> getProducts() {
    return new ArrayList<>(products.values());
  }

  public Product getProduct(Integer productId) {
    return products.get(productId);
  }

  private Map<Integer, Product> products = new HashMap<>();

  public ProductService() {
    _log.info("Initialize products in product service constructor");
    products.put(1, new Product(1, "Bulldog", 1000));
    products.put(2, new Product(2, "Chihuahua", 1500));
    products.put(3, new Product(3, "Labrador", 2000));
  }
}
